//
// Created by cjg on 2018/5/30.
// Copyright (c) 2018 chenjg. All rights reserved.
//

#import "CCNetModel.h"
#import <AFNetworking/AFNetworking.h>

@implementation CCNetModel {

}

- (instancetype)initWithData:(NSData *)data key:(NSString *)key fileName:(NSString *)fileName dataType:(NSString *)datatype {
    if (self = [self init]) {
        _data = data;
        _key = key;
        _fileName = fileName;
        _dataType = datatype;
    }
    return self;
}

- (void)addToFormData:(id <AFMultipartFormData>)formData {
    if (_data) {
        if (!self.dataType) {
            [formData appendPartWithFormData:_data name:_key];
        } else {
            [formData appendPartWithFileData:_data name:_key fileName:_fileName mimeType:_dataType];
        }
    }
}

@end